home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / HPACK78S.ZIP / arcdir.h < prev    next >
C/C++ Source or Header  |  1992-11-29  |  8KB  |  210 lines

  1. /****************************************************************************
  2. *                                                                            *
  3. *                            HPACK Multi-System Archiver                        *
  4. *                            ===========================                        *
  5. *                                                                            *
  6. *                Header File for the Directory Handling Routines                *
  7. *                            ARCDIR.H  Updated 14/03/92                        *
  8. *                                                                            *
  9. * This program is protected by copyright and as such any use or copying of    *
  10. *  this code for your own purposes directly or indirectly is highly uncool    *
  11. *                      and if you do so there will be....trubble.                *
  12. *                 And remember: We know where your kids go to school.            *
  13. *                                                                            *
  14. *        Copyright 1989 - 1992  Peter C.Gutmann.  All rights reserved        *
  15. *                                                                            *
  16. ****************************************************************************/
  17.  
  18. #ifndef _ARCDIR_DEFINED
  19.  
  20. #define _ARCDIR_DEFINED
  21.  
  22. #ifdef __MAC__
  23.   #include "filehdr.h"
  24.   #include "hpackio.h"
  25. #else
  26.   #include "filehdr.h"
  27.   #include "io/hpackio.h"
  28. #endif /* __MAC__ */
  29.  
  30. /* The size of a directory header as written to disk.  This must be defined
  31.    in terms of its constituent fields since some compilers will pad the
  32.    struct fields out for alignment reasons */
  33.  
  34. #define DIRHDRSIZE    ( sizeof( LONG ) + sizeof( WORD ) + sizeof( WORD ) )
  35.  
  36. /* The data structure for the list of file headers.  This contains the
  37.    global information which is identical for all versions of HPACK, plus
  38.    any mission-critical extra information needed by different OS's */
  39.  
  40. typedef struct FH {
  41.                   /* Information used on all systems */
  42.                   struct FH *next;        /* The next header in the list */
  43.                   struct FH *nextFile;    /* Next file in this directory */
  44.                   struct FH *prevFile;    /* Prev file in this directory */
  45.                   struct FH *nextLink;    /* The next linked file */
  46.                   struct FH *prevLink;    /* The previous linked file */
  47.                   FILEHDR data;            /* The file data itself */
  48.                   char *fileName;        /* The filename */
  49.                   BYTE *extraInfo;        /* Any extra information needed */
  50.                   long offset;            /* Offset of data from start of archive */
  51.                   WORD hType;            /* The type of the file (within HPACK) */
  52.                   WORD linkID;            /* The magic number of this link */
  53.                   BOOLEAN tagged;        /* Whether this file has been selected */
  54. #if defined( __UNIX__ )
  55.                   /* Information used to handle hard links on Unix systems */
  56.                   LONG fileLinkID;        /* The dev.no/inode used for links */
  57. #elif defined( __MAC__ )
  58.                   /* Information on file types/creators on Macintoshes */
  59.                   LONG type;            /* The file's type */
  60.                   LONG creator;            /* The file's creator */
  61. #elif defined( __ARC__ )
  62.                   /* Information on the file type on Archimedes' */
  63.                   WORD type;            /* The file's type */
  64. #elif defined( __IIGS__ )
  65.                   /* Information on the file types on Apple IIgs's */
  66.                   WORD type;            /* The file's type */
  67.                   LONG auxType;            /* The file's auxiliary type */
  68. #endif /* Various OS-specific extra information */
  69.                   } FILEHDRLIST;
  70.  
  71. /* The data structures for the list of directories */
  72.  
  73. typedef struct DH {
  74.                   WORD dirIndex;        /* The index of this directory */
  75.                   WORD next;            /* The next header in the list */
  76. /*                  struct DH *next;        // The next header in the list */
  77.                   struct DH *nextDir;    /* Next dir in this directory */
  78.                   struct DH *prevDir;    /* Prev dir in this directory */
  79.                   struct DH *nextLink;    /* The next linked directory */
  80.                   struct DH *prevLink;    /* The previous linked directory */
  81.                   DIRHDR data;            /* The directory data */
  82.                   char *dirName;        /* The directory name */
  83.                   long offset;            /* Offset of data from start of dir
  84.                                            directory data area */
  85.                   FILEHDRLIST *fileInDirListHead;    /* Start of the list of
  86.                                            files in this directory */
  87.                   FILEHDRLIST *fileInDirListTail;    /* End of the list of
  88.                                            files in this directory */
  89.                   struct DH *dirInDirListHead;        /* Start of the list of
  90.                                            dirs in this directory */
  91.                   struct DH *dirInDirListTail;        /* End of the list of
  92.                                            dirs in this directory */
  93.                   WORD hType;            /* The type of the directory (within HPACK) */
  94.                   WORD linkID;            /* The magic number of this link */
  95.                   BOOLEAN tagged;        /* Whether this dir.has been selected */
  96.                   } DIRHDRLIST;
  97.  
  98. /* The data structure for the list of archive parts for a multi-part archive */
  99.  
  100. typedef struct PL {
  101.                   struct PL *next;        /* The next header in the list */
  102.                   long segEnd;            /* Extent of this segment */
  103.                   } PARTSIZELIST;
  104.  
  105. /* The end marker for various lists */
  106.  
  107. #define END_MARKER        0xFFFF
  108.  
  109. /* The directory index number for the root directory */
  110.  
  111. #define ROOT_DIR        0
  112.  
  113. /* The magic number for a non-linked file */
  114.  
  115. #define NO_LINK            0
  116.  
  117. /* The types of path match which matchPath() can return */
  118.  
  119. enum { PATH_NOMATCH, PATH_PARTIALMATCH, PATH_FULLMATCH };
  120.  
  121. /* Whether we want readArcDir() to save the directory data to a temporary
  122.    file (this is necessary since it will be overwritten during an ADD) */
  123.  
  124. #define SAVE_DIR_DATA    TRUE
  125.  
  126. /* The magic ID and temporary name extensions for HPACK archives */
  127.  
  128. extern char HPACK_ID[];
  129.  
  130. #define HPACK_ID_SIZE    4            /* 'HPAK' */
  131.  
  132. extern char TEMP_EXT[], DIRTEMP_EXT[], SECTEMP_EXT[];
  133.  
  134. /* Bit masks for the fileKludge in the archive trailer */
  135.  
  136. #define SPECIAL_MULTIPART    0x01    /* Multipart archive */
  137. #define SPECIAL_MULTIEND    0x02    /* Last part of multipart archive */
  138. #define SPECIAL_SECURED        0x04    /* Secured archive */
  139. #define SPECIAL_ENCRYPTED    0x08    /* Encrypted archive */
  140. #define SPECIAL_BLOCK        0x10    /* Block compressed archive */
  141.  
  142. /* Some global vars, defined in ARCDIR.C */
  143.  
  144. extern FILEHDRLIST *fileHdrCurrPtr, *fileHdrStartPtr;
  145. extern int currEntry, currPart, lastPart;
  146. extern long segmentEnd, endPosition;
  147.  
  148. /* Prototypes for functions in ARCDIR.C */
  149.  
  150. void initArcDir( void );
  151. void endArcDir( void );
  152. void resetArcDir( void );
  153. #ifdef __MSDOS__
  154.   void resetArcDirMem( void );
  155. #endif /* __MSDOS__ */
  156. void readArcDir( const BOOLEAN doSaveDirData );
  157. void writeArcDir( void );
  158. void addFileHeader( FILEHDR *theHeader, WORD hType, BYTE extraInfo, WORD linkID );
  159. void deleteFileHeader( FILEHDRLIST *theHeader );
  160. int writeFileHeader( FILEHDRLIST *theHeader );
  161. BOOLEAN addFileName( const WORD dirIndex, const WORD hType, const char *fileName );
  162. void deleteLastFileName( void );
  163. void addDirName( char *dirName, const LONG dirTime );
  164. int addDirData( WORD tagID, const int store, LONG dataLength, LONG uncoprDataLength );
  165. void movetoDirData( void );
  166. inline void setArchiveCwd( const WORD dirIndex );
  167. inline void popDir( void );
  168. inline WORD getParent( const WORD dirIndex );
  169. void sortFiles( const WORD dirIndex );
  170. FILEHDRLIST *findFileLinkChain( WORD linkID );
  171. DIRHDRLIST *findDirLinkChain( WORD linkID );
  172. inline FILEHDRLIST *getFirstFileEntry( const WORD dirIndex );
  173. inline FILEHDRLIST *getNextFileEntry( void );
  174. inline FILEHDRLIST *getPrevFileEntry( void );
  175. inline DIRHDRLIST *getFirstDirEntry( const WORD dirIndex );
  176. inline DIRHDRLIST *getNextDirEntry( void );
  177. inline DIRHDRLIST *getPrevDirEntry( void );
  178. inline WORD getFirstDir( void );
  179. inline WORD getNextDir( void );
  180. int matchPath( const char *filePath, const int pathLen, WORD *dirIndex );
  181. inline char *getDirName( const WORD dirIndex );
  182. inline LONG getDirTime( const WORD dirIndex );
  183. inline void setDirTime( const WORD dirIndex, const LONG time );
  184. inline LONG getDirAuxDatalen( const WORD dirIndex );
  185. inline BOOLEAN getDirTaggedStatus( const WORD dirIndex );
  186. inline void setDirTaggedStatus( const WORD dirIndex );
  187. void getArcdirState( FILEHDRLIST **hdrListEnd, int *dirListEnd );
  188. void setArcdirState( FILEHDRLIST *hdrListEnd, const int dirListEnd );
  189. long getCoprDataLength( void );
  190. int computeHeaderSize( const FILEHDR *theHeader, const BYTE extraInfo );
  191. void addPartSize( const long partSize );
  192. int getPartNumber( const long offset );
  193. long getPartSize( int partNumber );
  194. void getPart( const int thePart );
  195. void selectFile( FILEHDRLIST *fileHeader, BOOLEAN status );
  196. void selectDir( DIRHDRLIST *dirHeader, BOOLEAN status );
  197. void selectDirNo( const WORD dirNo, BOOLEAN status );
  198. void selectDirNoContents( const WORD dirNo, BOOLEAN status );
  199.  
  200. /* Prototypes for supplementary functions in ARCDIR.C used only by some OS's */
  201.  
  202. #if defined( __UNIX__ )
  203.   BOOLEAN checkForLink( const LONG linkID );
  204.   void addLinkInfo( const LONG linkID );
  205. #elif defined( __MAC__ )
  206.   void addTypeInfo( LONG owner, LONG creator );
  207. #endif /* Various OS-specific supplementary functions */
  208.  
  209. #endif
  210.